﻿
@{
    ViewBag.Title = "添加楼盘";
}
@model KTD.Web.Models.VD.HouseCUD

<style type="text/css">
    .layui-form-label {
        width: 100px;
    }

    .layui-form-checkbox {
        position: absolute;
        top: 10px;
        right: 5px;
    }

    .delete {
        position: absolute;
        top: 10px;
        right: 5px;
        background-color: black;
        color: white;
        opacity: 0.5;
        cursor: pointer;
    }
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link href="~/lib/Context/themes/default.min.css" rel="stylesheet" />
<link href="~/lib/Context/basicContext.min.css" rel="stylesheet" />

@{
    var oldImgRoot = "";
    if (Model.memberId == null || Model.memberId == 0)
    {
        oldImgRoot = "http://wx.attch.we.qsace.com/";
    }
}
<div class="x-body" id="saveResult" style="width:100%;">
    <form method="post">
        @Html.HiddenFor(model => model.channel)
        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.memberId)
        @Html.HiddenFor(model => model.CreateDateTime)
        <div class="layui-form">
            @if (Model.channel == "sale")
            {
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>区域名称
                        </label>
                        <div class="layui-input-inline">
                            @Html.DropDownListFor(model => model.areaname, ViewBag.houseareaid as IEnumerable<SelectListItem>, new { @class = "layui-input", @lay_filter = "areaname" })
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>楼盘名称
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.title, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>房源类型
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.housetype, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>姓名
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.name, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>联系方式
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.tel, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>支付方式
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.payway, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>



                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>租金/售价
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.money, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>房型
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.roomtype, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>租/售
                        </label>
                        <div class="layui-input-inline">
                            @*@Html.TextBoxFor(model => model.letway, new { @class = "layui-input" })*@
                            @Html.DropDownListFor(model => model.letway, ViewBag.saleTypesList as IEnumerable<SelectListItem>, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>占地面积
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.area, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>楼层
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.floor, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>装修程度
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.decorate, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>来源
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.source, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>地址
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.address, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>特点
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.special, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>


            }
            else
            {
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>区域名称
                        </label>
                        <div class="layui-input-inline">
                            @Html.DropDownListFor(model => model.areaname, ViewBag.houseareaid as IEnumerable<SelectListItem>, new { @class = "layui-input", @lay_filter = "areaname" })
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>楼盘名称
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.housename, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>楼盘类型
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.housetype, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>开发商
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.companyname, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>项目地址
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.houseaddress, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>均价
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.houseprice, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>



                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>占地面积
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.mianji, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>在售业态
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.onSaleType, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>是否通气
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.tongqi, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>在售产品
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.onSaleProduct, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>可售套数
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.onSaleCount, new { @class = "layui-input",@type="number" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>面积区间
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.housearea, new { @class = "layui-input" })
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>单价
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.price, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>总价区间
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.zongjia, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>总层数
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.zongCengShu, new { @class = "layui-input",@type="number" })
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>梯户比
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.cenghubi, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>层高
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.cenggao, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>产权年限
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.year, new { @class = "layui-input" })
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>物管公司
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.opensaletime, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>物业费
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.wuyefei, new { @class = "layui-input" })
                        </div>
                    </div>

                </div>

                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>容积率
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.rongJiLv, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>绿化率
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.housegreenrate, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>公摊
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.gongtan, new { @class = "layui-input" })
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>商管公司
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.shangGuan, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>交房时间
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.jiaoFangShiJian, new { @class = "layui-input" })
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>车位比
                        </label>
                        <div class="layui-input-inline">
                            @Html.TextBoxFor(model => model.cheWeiBi, new { @class = "layui-input" })
                        </div>
                    </div>

                </div>
            }


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>经度
                    </label>
                    <div class="layui-input-inline">
                        @Html.TextBoxFor(model => model.lng, new { @class = "layui-input" })
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>纬度
                    </label>
                    <div class="layui-input-inline">

                        @Html.TextBoxFor(model => model.lat, new { @class = "layui-input" })
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="btn-default" id="MapBtn">查看地图</button>
                    <div class="layui-input-inline" id="selectLocation" style="height:700px;width:800px;display:none;">
                        <div>
                            @*@Html.TextBoxFor(model => model.address)*@
                            <input id="place" width="500" />
                            <button id="addressBtn">搜索</button>
                        </div>
                        <div id="map" style="height:600px;width:800px;"></div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>佣金
                    </label>
                    <div class="layui-input-inline">
                        @Html.TextBoxFor(model => model.fxmoney, new { @class = "layui-input" })
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>状态
                    </label>
                    <div class="layui-input-inline">

                        @Html.EnumDropDownListFor(model => model.status, new { @class = "layui-input" })
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>热度
                    </label>
                    <div class="layui-input-inline">
                        @Html.TextBoxFor(model => model.hot, new { @class = "layui-input", type = "number" })
                    </div>
                </div>
                <div class="layui-inline">
                    @Html.HiddenFor(n => n.thumb)
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>封面图
                    </label>
                    <div class="layui-input-inline">
                        <img id="imgThumb" src="@Model.thumb" width="200" height="200" />
                    </div>
                </div>
            </div>

            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this">效果图</li>
                    <li class="">户型图</li>
                    <li class="">样板间图</li>
                    <li class="">周边图</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">

                        @Html.HiddenFor(n => n.thumb_url)
                        <div class="imgs">
                            @if (!string.IsNullOrEmpty(Model.thumb_url))
                            {

                                foreach (var img in Model.thumb_url.Split(','))
                                {
                                    <div class="layui-input-inline" style="position:relative">
                                        <img class="thumb_url" src="@(oldImgRoot+img)" width="200" height="200" />
                                        <i class="layui-icon delete" title="删除" onclick="deleteImg(this,'@img','thumb_url');">&#xe640;</i>
                                        @*<input type="checkbox" lay-skin="primary" data-type="thumb_url" />*@
                                    </div>
                                }

                            }
                        </div>
                        <input type="file" id="File1" multiple="multiple" data-type="thumb_url" class="uploadFile" style="display:none;" />
                        <button class="layui-btn" onclick="javascript: $('#File1').click(); return false;"><i class="layui-icon"></i>上传效果图</button>
                    </div>
                    <div class="layui-tab-item">
                        @Html.HiddenFor(n => n.thumb_1)
                        <div class="imgs">
                            @if (!string.IsNullOrEmpty(Model.thumb_1))
                            {

                                foreach (var img in Model.thumb_1.Split(','))
                                {
                                    <div class="layui-input-inline" style="position:relative">
                                        <img src="@(oldImgRoot+img)" width="200" height="200" />
                                        <i class="layui-icon delete" title="删除" onclick="deleteImg(this,'@img','thumb_1');">&#xe640;</i>
                                    </div>
                                }


                            }
                        </div>
                        <input type="file" id="File2" multiple="multiple" data-type="thumb_1" class="uploadFile" style="display:none;" />
                        <button class="layui-btn" onclick="javascript: $('#File2').click(); return false;"><i class="layui-icon"></i>上传户型图</button>
                    </div>
                    <div class="layui-tab-item">
                        @Html.HiddenFor(n => n.thumb_2)
                        <div class="imgs">
                            @if (!string.IsNullOrEmpty(Model.thumb_2))
                            {

                                foreach (var img in Model.thumb_2.Split(','))
                                {
                                    <div class="layui-input-inline" style="position:relative">
                                        <img src="@(oldImgRoot+img)" width="200" height="200" />
                                        <i class="layui-icon delete" title="删除" onclick="deleteImg(this,'@img','thumb_2');">&#xe640;</i>
                                    </div>
                                }

                            }
                        </div>
                        <input type="file" id="File3" multiple="multiple" data-type="thumb_2" class="uploadFile" style="display:none;" />
                        <button class="layui-btn" onclick="javascript: $('#File3').click(); return false;"><i class="layui-icon"></i>上传样板间图</button>
                    </div>
                    <div class="layui-tab-item">
                        @Html.HiddenFor(n => n.thumb_3)
                        <div class="imgs">
                            @if (!string.IsNullOrEmpty(Model.thumb_3))
                            {

                                foreach (var img in Model.thumb_3.Split(','))
                                {
                                    <div class="layui-input-inline" style="position:relative">
                                        <img src="@(oldImgRoot+img)" width="200" height="200" />
                                        <i class="layui-icon delete" title="删除" onclick="deleteImg(this,'@img','thumb_3');">&#xe640;</i>
                                    </div>
                                }

                            }
                        </div>
                        <input type="file" id="File4" data-type="thumb_3" class="uploadFile" style="display:none;" />
                        <button class="layui-btn" onclick="javascript: $('#File4').click(); return false;"><i class="layui-icon"></i>上传周边图</button>
                    </div>
                </div>
            </div>



            <label for="L_email" class="layui-form-label">
                <span class="x-red">*</span>楼盘简介
            </label>
            <div class="layui-form-item">


                @Html.TextAreaFor(model => model.content, new { @class = "layui-input", style = "width:100%;height:200px;display:none;" })
                <div id="editor">
                    <p>
                        @Html.Raw(HttpUtility.HtmlDecode(Model.content))
                    </p>
                </div>

            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <input id="save" type="submit" class="layui-btn" value="提交" lay-filter="add" lay-submit="" />
            </div>

        </div>

    </form>
</div>



@section scripts{
    <script src="~/Scripts/wangEditor.min.js"></script>
    <script src="~/lib/Context/basicContext.min.js"></script>
    <script src="~/Scripts/tool.js"></script>
    <script src="https://map.qq.com/api/js?v=2.exp&key=d84d6d83e0e51e481e50454ccbe8986b"></script>
    <script>

        	var onClick = function(e) {
                var clicked = function () {
                    var src = $(e.currentTarget).attr('src');
                    $("#thumb").val(src);
                    $("#imgThumb").attr("src",src);
                }

			var items = [
				{ title: '设为主页', icon: 'ion-heart', fn: clicked }

			]

			basicContext.show(items, e.originalEvent)

		}
        var marker;
        $(document).ready(function () {
             $('.thumb_url').on('contextmenu', onClick)
            var lat = 30.666266, lng = 104.069366;
            if (@Model.lat== 0 &&@Model.lng== 0) {


                $.ajax({

                    url: "/Area/FindByName",
                    data: {
                        areaName: $("#areaname").val()
                    },
                    type: "get",
                    async: false,
                    success: function (data) {
                        if (data.success) {
                            lat = data.data.lat;
                            lng = data.data.lng;
                        }
                    }
                });
            }
            else {
                lat =@Model.lat;
                lng=@Model.lng;
            }
            var center = new qq.maps.LatLng(lat,lng);
            var map = new qq.maps.Map(document.getElementById("map"), {
                    zoom: 13,
                    // 地图的中心地理坐标。
                    center:center
            });


            marker= new qq.maps.Marker({
                position: center,
                animation: qq.maps.MarkerAnimation.DROP,
                map: map
            });

               //地址和经纬度之间进行转换服务
            geocoder = new qq.maps.Geocoder({
                //设置服务请求成功的回调函数
                complete: function (result) {
                   map.setCenter(result.detail.location);
                     marker.setMap(null);
                     marker = new qq.maps.Marker({
                        map:map,
                        position: result.detail.location
                     });
                    $("#lat").val( result.detail.location.lat);
                     $("#lng").val(result.detail.location.lng);
                    //$("#address").val(result.detail.address.replace("中国", ""));
                },
                //若服务请求失败，则运行以下函数
                error: function() {
                    alert("请输入正确的地址，并确保输入的地址在所选区县内！！！");
                }
            });


              //查询poi类信息
            searchService = new qq.maps.SearchService({
                complete: function (results) {
                    if (results.detail.pois == undefined) {
                        alert("请输入正确的地址，并确保输入的地址在所选区县内！");
                        return;
                    }
                    var poi = results.detail.pois[0];
                    map.setCenter(poi.latLng);
                     marker.setMap(null);
                     marker = new qq.maps.Marker({
                        map:map,
                        position: poi.latLng
                     });
                    // marker.setLabel(poi.address);
                    marker.setTitle(poi.address + poi.name);
                    $("#lat").val( poi.latLng.lat);
                     $("#lng").val(poi.latLng.lng);
                },
                 //若服务请求失败，则运行以下函数
                error: function() {
                    alert("请输入正确的地址！！！");
                }
            });

             $("#addressBtn").click(function () {

                var address = document.getElementById("place").value;
                var areaName = document.getElementById("areaname").value;
                //通过getLocation();方法获取位置信息值
                //geocoder.getLocation(address);
                searchService.setLocation(areaName);             //设置默认检索范围（默认为全国），类型可以是坐标或指定的城市名称。
                searchService.setPageIndex(0);         //设置检索的特定页数。
                searchService.setPageCapacity(1);   //设置每页返回的结果数量。
                searchService.search(address);

                return false;
            });
                    //添加监听事件   获取鼠标单击事件
            qq.maps.event.addListener(map, 'click', function (event) {

                 marker.setMap(null);
                 marker = new qq.maps.Marker({
                    position: event.latLng,
                    map: map
                 });
                console.log(event);

                $("#lat").val(event.latLng.lat);
                $("#lng").val(event.latLng.lng);
               geocoder.getAddress(event.latLng);
            });

                    layui.use(['element','form'], function(){
                    var element = layui.element;
                    var form = layui.form;
                    var  layer = layui.layer;

                  form.on('select(areaname)', function (data) {
                      debugger;
                      $.ajax({

                            url: "/Area/FindByName",
                            data: {
                                areaName: $("#areaname").val()
                            },
                            type: "get",

                            success: function (data) {
                                if (data.success) {
                                     var center = new qq.maps.LatLng(data.data.lat, data.data.lng);
                                    map.setCenter(center);
                                    marker.setMap(null);
                                    marker = new qq.maps.Marker({
                                        position: center,
                                        animation: qq.maps.MarkerAnimation.DROP,
                                        map: map
                                     });
                                }
                            }
                        });
                  });
               })

		})
       function fileLoad(ele) {
                //④创建一个formData对象
                var formData = new FormData();
                //⑤获取传入元素的val
                var name = $(ele).val();
                //⑥获取files
                debugger;
                var file = $(ele)[0].files;

                //⑦将name 和 files 添加到formData中，键值对形式
                for (i = 0; i < file.length;i++ ) {
                    formData.append("File", file[i]);
                }

                formData.append("OSSId", "@ViewBag.Id");
                $.ajax({
                    url: "/Attachment/Create",
                    type: 'POST',
                    data: formData,
                    processData: false,// ⑧告诉jQuery不要去处理发送的数据
                    contentType: false, // ⑨告诉jQuery不要去设置Content-Type请求头
                    //beforeSend: function () {
                    //    //⑩发送之前的动作
                    //    alert("我还没开始发送呢");
                    //},
                    success: function (data) {
                        //11成功后的动作
                        layer.msg('上传成功!', { icon: 1, time: 1000 });
                         debugger;
                        var type = $(ele).attr("data-type");
                        if ($("#" + type).val() == "") {
                            $("#" + type).val(data.url);
                        } else {
                            $("#" + type).val($("#" + type).val()+"," + data.url)
                        }
                        var urls = data.url.split(',');
                        for (i = 0; i < urls.length; i++) {
                             var dom = "<div class='layui-input-inline' style='position:relative'>"
                                +"<img  class='thumb_url1'  src='"+urls[i]+"' width='200' height='200' />"
                            + "<i class='layui-icon delete' title='删除' onclick='deleteImg(this,\""+data.url+"\",\""+type+"\");'>&#xe640;</i>"
                                + "</div>";
                             $(dom).appendTo($(ele).parent().find(".imgs")[0]);
                        }




                        $('.thumb_url1').on('contextmenu', onClick)
                    }
                    ,
                    error: function (responseStr) {
                        //12出错后的动作
                        alert("出错啦");
                    }
                });
        }


        function cleanWord(html) {
            html = html.replace(/<o:p> <\/o:p>/g, "");
            html = html.replace(/o:/g, "");
            html = html.replace(/<font>/g, "");
            html = html.replace(/<FONT>/g, "");
            html = html.replace(/<span>/g, "");
            html = html.replace(/<SPAN>/g, "");
            html = html.replace(/<SPANlang=EN-US>/g, "");
            html = html.replace(/<P>/g, "");
            html = html.replace(/<\/P>/g, "");
            html = html.replace(/<\/SPAN>/g, "");
            return html;
        }

         $(function () {
               var E = window.wangEditor
             var editor = new E('#editor');
             editor.customConfig.pasteFilterStyle = false;
             editor.customConfig.pasteTextHandle = function (content) {
                 // content 即粘贴过来的内容（html 或 纯文本），可进行自定义处理然后返回
                 if (content == '' && !content) return ''
                 let str = content;
                 //处理的标签里的多余代码
                 str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '');
                 str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '');
                 //str = str.replace(/<style>[\s\S]*?<\/style>/ig, '');
                 str = str.replace('/(\\n|\\r| class=(")?Mso[a-zA-Z]+(")?)/g', '');
                 let reg = new RegExp('<!--(.*?)-->', 'g')
                 str = str.replace(reg, '');
                 //str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
                 //str = str.replace(/<\/?[^>]*>/g, '')
                 // str = str.replace(/[ | ]*\n/g, '\n')
                 // str = str.replace(/&nbsp;/ig, '')
                 console.log('富文本的content', JSON.parse(JSON.stringify(content)));
                 console.log('****str修改后的content str', str);
                 return str;
             }
                // 或者 var editor = new E( document.getElementById('editor') )
             editor.create();
              $("#save").click(function () {
                $("#content").val(editor.txt.html());
                return true;
              });


             $("#MapBtn").click(function () {
                 layer.open({
                    type: 1,
                    area: ['800px', '700px'],
                    fix: false, //不固定
                    maxmin: true,
                    shadeClose: true,
                    shade:0.4,
                    title: "地图选择",
                    content:  $('#selectLocation')
                 });
                 return false;
             })

                // ①为input设定change事件
             $(".uploadFile").change(function () {
                    //    ②如果value不为空，调用文件加载方法
                    if ($(this).val() != "") {
                        fileLoad(this);

                    }
                })
         });
        function deleteImg(e,img, id) {
            var imgs = $('#' + id).val();
            if (imgs.indexOf(img + ',') != -1) {
                $('#' + id).val(imgs.replace(img + ',', ''));
            } else if (imgs.indexOf(',') != -1) {
                $('#' + id).val(imgs.replace(',' + img, ''));
            } else {
                $('#' + id).val(imgs.replace(img, ''));
            }
            $(e).parent().remove();
        }
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;

            //自定义验证规则
            form.verify({
                nikename: function (value) {
                    if (value.length < 5) {
                        return '昵称至少得5个字符啊';
                    }
                }
                , pass: [/(.+){6,12}$/, '密码必须6到12位']
                , repass: function (value) {
                    if ($('#L_pass').val() != $('#L_repass').val()) {
                        return '两次密码不一致';
                    }
                }
            });

        });

    </script>
}